typedef void EventCallback(arg);

class EventMineKeys {
  static const String ExitLogin = "ExitLogin"; // 退出登陆到home页面

  static const String MineChangeTabbarIndex = "MineChangeTabbarIndex";// 个人中心切换tab

  static const String UpdateMineInfo = "UpdateMineInfo"; // 个人中心用户信息更新

  static const String RecordLastLocation = "RecordLastLocation"; // 记录上次浏览的位置

  static const String HiddenTabbar = "HiddenTabbar"; // 隐藏tabbar

  static const String IMMessageCount = "IMMessageCount"; // 隐藏tabbar

  static const String IMGroupRefresh = "IMGroupRefresh"; // 分组操作刷新

  static const String RaiseAction = "RaiseAction"; // 刷新我关注的用户

  static const String RefreshMessageList = "RefreshMessageList"; // 刷新消息列表

  static const String AlertDressupWidget = "AlertDressupWidget"; // 弹起换装
}

class EventMineBus {
  factory EventMineBus() => _getInstance();
  static EventMineBus get instance => _getInstance();
  static EventMineBus _instance;
  
  EventMineBus._internal(){
    // init
  }
  static EventMineBus _getInstance() {
    if(_instance == null) {
      _instance = EventMineBus._internal();
    }
    return _instance;
  }

  Map<String, EventCallback> _events = {};

  // 添加监听
  void addListener(String eventkey, EventCallback callback) {
    if(eventkey == null || callback == null) return;
    _events[eventkey] = callback;
  }

  // 移除监听
  void removeListener(String eventKey) {
    if(eventKey == null) return;
    _events.remove(eventKey);
  }

  void commit(String eventKey, Object arg) {
    if(eventKey == null) return;
    EventCallback callback = _events[eventKey];
    if(callback != null) {
      callback(arg);
    }
  }
}